Creating a Shop API of GET items with lambda and API Gateway using AWS

Creating a Shop API of GET items with lambda and API Gateway using AWS

Clock Icon2022.01.30

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

API

It stands for Application Program interface which helps in connection of two applications, computers, or between computer programs to talk to each other. It is used to access data, server software, or other applications and has been around for some time. Each time anyone uses a particular app for weather updates or good restaurants in an app API is used.

API Gateway

A fully managed service that makes developers easily create, publish, maintain, monitor, and secure APIs at any scale. API Gateway can be used to create Restful APIs and WebSocket APIs which have real-time two-way communication applications. It is a front door for applications to access data, business logic, or functionality from your backend services.

AWS Lambda

A serverless compute service which runs code as a reply to events and automatically takes care of the bottom resources. It runs code on high availability compute infrastructure and performs all the administration of the compute resources. A few examples are HTTP requests via Amazon API Gateway, changes to objects in S3, and many others.

Demo

Search for API Gateway in the AWS Console and click build on HTTP API Give an API Name and click next No changes right now in the configure routes and click next Give a name to the stage and keep the auto-deploy as the default Review and click on create Adding a path in the routes and click create Choosing the GET method, entering the path, and clicking create Go to lambda and click on create function Click on author from scratch, give a function name, keep other things as default and click on create function Adding items in code source and clicking deploy Going back to Routes of API Gateway click on GET and click on attach integration In the integration target choose “lambda function”, integration target “get item” and click create Copy the invoke URL of API Paste the invoke URL in the new tab with “/item/34” and get the result Paste the invoke URL in the new tab with “/item/78” and get the result Paste the invoke URL in the new tab with “/item/98” and get the result

Share this article

facebook logohatena logotwitter logo

© Classmethod, Inc. All rights reserved.